Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

[v2.0] Move psk store to user #237

Merged
merged 14 commits into from
May 31, 2022
Merged

Conversation

DyrellC
Copy link
Contributor

@DyrellC DyrellC commented May 20, 2022

Description of change

Moves the psks HashMap out of KeyStore and into User directly.

  • Keyloads now need specified psks when sending
  • Keyloads iterate over provided psks and apply Permissioned::Read to each of them when masking key
  • Identity::Psk and Identifier::Psk have been removed

Type of change

  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How the change has been tested

  • Examples updated
  • Doc Tests updated

lets/src/message/content.rs Outdated Show resolved Hide resolved
lets/src/id/identity.rs Outdated Show resolved Hide resolved
lets/src/id/permission.rs Outdated Show resolved Hide resolved
streams/src/api/key_store.rs Show resolved Hide resolved
streams/src/api/key_store.rs Outdated Show resolved Hide resolved
streams/src/api/user.rs Outdated Show resolved Hide resolved
streams/src/api/user.rs Outdated Show resolved Hide resolved
streams/src/api/user.rs Outdated Show resolved Hide resolved
streams/src/api/user.rs Outdated Show resolved Hide resolved
streams/src/api/user.rs Outdated Show resolved Hide resolved
fork.mask(&mut psk_id)?;

let mut masked_key = [0u8; KEY_SIZE];
if let Some(psk) = keyload.psk_store.get(&psk_id) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could check here if the key has not yet been decrypted (key.is_none()), in order to avoid decrypting it multiple times unnecessarily

Copy link
Contributor

@arnauorriols arnauorriols left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great. Just one old comment pending to address, but everything else is ready to merge in my opinion.

Copy link
Contributor

@kwek20 kwek20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am i correct in thinking we dont really need PskId anymore? We should remove it in that case

#[cfg(feature = "did")]
Identifier::DID(did) => {
let oneof = Uint8::new(2);
let oneof = Uint8::new(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is fine now since were doing a large rewrite, but we should keep in mind in the future, that we should not change these numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

self.send_keyload(
link_to,
// Alas, must collect to release the &self immutable borrow
self.subscribers().map(Permissioned::Read).collect::<Vec<_>>(),
subscribers,
psks,
)
.await
}

pub async fn send_keyload_for_all_rw(&mut self, link_to: MsgId) -> Result<SendResponse<TSR>> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm im not sure how this method passed review earlier. Did we get requested to add this method, or are we sure this will be needed in many cases? If thats the case, should we change the default? Alternatively, i think a way to specify the "Permisison type" per identifier is better. (not in this PR, but should be given thought. (I am referring to timed permissions)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth addressing when we get to the high level API rewrite, because defining the Permissions more directly will make more sense semantically once send_keyload assumes the new change_permissions() definition

@DyrellC
Copy link
Contributor Author

DyrellC commented May 31, 2022

@kwek20 #241 Arnau made this issue after this conversation: #237 (comment). What's your opinion?

Copy link
Contributor

@kwek20 kwek20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave a comment on the issue regarding PskId, as this PR is just moving it, it can be done in a new one. (if we decide to remove it)

@DyrellC DyrellC merged commit 8a959a4 into iotaledger:v2.0-dev May 31, 2022
@DyrellC DyrellC deleted the v2.0/move-psk-store branch March 13, 2023 23:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants